import * as types from "../mutation-types";
const state = {
  device: {
    isMobile: false,
    isTablet: false
  },
  sidebar: {
    open: false
  },
  effect: {
    translate3d: true
  },
  header: {
    open: true,
    active: "Home",
    items: [
      { name: "主页", path: "home" },
      { name: "聊天记录", path: "notification" }
    ],
    current: null,
    searchText: "",
    skills: [
      { key: "张俊", text: "张俊", value: "张俊" }, 
      { key: "林新辉", text: "林新辉", value: "林新辉" },
      { key: "张志叶", text: "张志叶", value: "张志叶" },
      { key: "李佳佳", text: "李佳佳", value: "李佳佳" }, 
      { key: "林过", text: "林过", value: "林过" },
      { key: "叶杨", text: "叶杨", value: "叶杨" }]
  },
  mobileNavigationBar: {
    open: true
  },
  search: {
    modal: {
      open: false,
      filter: {
        open: false
      }
    }
  },
  notification: {
    modal: {
      open: false
    }
  }
};

const mutations = {
  [types.TOGGLE_DEVICE](state, device) {
    state.device.isMobile = device === "mobile";
    state.device.isTablet = device === "tablet";
  },
  [types.TOGGLE_SIDEBAR](state) {
    state.sidebar.open = !state.sidebar.open;
  },
  [types.HANDLE_SIDEBAR](state, playload) {
    state.sidebar.open = playload;
  },
  [types.SELECT_HEADER_MENU](state, playload) {
    state.header.active = playload;
  },
  [types.SET_HEADER_MENU](state, playload) {
    state.header[playload.key] = playload.value;
  },
  [types.TOGGLE_HEADER](state) {
    state.header.open = !state.header.open;
  },
  [types.HANDLE_HEADER](state, playload) {
    state.header.open = playload;
  },
  [types.TOGGLE_SEARCH_MODAL](state) {
    state.search.modal.open = !state.search.modal.open;
  },
  [types.HANDLE_SEARCH_MODAL](state, playload) {
    state.search.modal.open = playload;
  },
  [types.TOGGLE_SEARCH_MODAL_FILTER](state) {
    state.search.modal.filter.open = !state.search.modal.filter.open;
  },
  [types.HANDLE_SEARCH_MODAL_FILTER](state, playload) {
    state.search.modal.filter.open = playload;
  },
  [types.TOGGLE_MOBILENAVIGAIONBAR](state) {
    state.mobileNavigationBar.open = !state.mobileNavigationBar.open;
  },
  [types.HANDLE_MOBILENAVIGAIONBAR](state, playload) {
    state.mobileNavigationBar.open = playload;
  },
  [types.TOGGLE_NOTIFICATION_MODAL](state) {
    state.notification.modal.open = !state.notification.modal.open;
  },
  [types.HANDLE_NOTIFICATION_MODAL](state, playload) {
    state.notification.modal.open = playload;
  }
};

export default {
  state,
  mutations
};
